//
// Created by hsj on 2022/1/14.
//
#include <iostream>
#include "t_class_cast.h"

namespace my_class_cast{
   using std::cout;
   using std::endl;

    Stonewt::Stonewt(double lbs){
           stone = int (lbs);
           pds_left = int (lbs) % static_cast<unsigned int>(Stonewt::SM::Lbs_per_stn) + lbs - int(lbs);
           pounds = lbs;
    }

    Stonewt::Stonewt(int stn,double lbs){
           stone = stn;
           pds_left = lbs;
           pounds = stn * static_cast<unsigned int>(Stonewt::SM::Lbs_per_stn) + lbs;
    }

    Stonewt::Stonewt(){
           stone = pounds = pds_left = 0;
    }

    Stonewt::~Stonewt(){
        //TODO
    }

    void Stonewt::showLbs()const{
        cout<<"stone: "<<stone<<" pds_left: "<<pds_left<<" pounds."<<endl;
    }

    void Stonewt::showStn()const{
        cout<<"pounds: "<<pounds<<endl;
    }

    //转换函数：
    // 必须是类方法；
    // 不能指定返回值；
    // 不能有参数；
    Stonewt::operator int()const{
        return int(pounds + 0.5);
    }
    Stonewt::operator double()const{
        return pounds;
    }
}